package com.op.pojo;

import com.op.entity.Question;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.SneakyThrows;

/**
 * ClassName： PriorityQuestion
 * Date： 2021/10/27 10:18
 *
 * @author 孤焰
 * @version 1.0
 **/

@Data
@ApiModel("题目排序类")
@AllArgsConstructor
@NoArgsConstructor
public class PriorityQuestion implements Comparable {
    @ApiModelProperty("题目信息")
    private Question question;

    @ApiModelProperty("题目优先级")
    private Double score;

    @SneakyThrows
    @Override
    public int compareTo(Object o) {
        if (o instanceof PriorityQuestion) {
            return (int) (score - ((PriorityQuestion) o).score);
        } else {
            throw new Exception("题目比较异常,形参所属类:" + o.getClass().getName());
        }
    }
}
